<%--
  Created by IntelliJ IDEA.
  User: lt
  Date: 2018/5/24
  Time: 20:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro" %>
<c:set var="contextPath" value="${pageContext.request.contextPath}"></c:set>
<c:set var="id" value="${pageContext.request.getParameter('id')}"></c:set>

<title>门店 - 快速要货单商品详情</title>
<%--<link rel="stylesheet" href="${contextPath}/static/layer/css/layui.css" media="all">--%>
<link rel="stylesheet" href="${contextPath}/static/ace/components/_mod/jquery-ui/jquery-ui.css"/>
<%--<link rel="stylesheet" href="${contextPath}/static/statistics/css/bootstrap-datetimepicker.min.css">--%>
<link rel="stylesheet"
      href="${contextPath}/static/ace/components/bootstrap-datepicker/dist/css/bootstrap-datepicker3.css"/>
<link rel="stylesheet" href="${contextPath}/static/ace/components/_mod/jqgrid/ui.jqgrid.css"/>
<script src="${contextPath}/static/statistics/js/bootstrap-datetimepicker.min.js"></script>
<%--<script src="${contextPath}/static/statistics/js/bootstrap-datetimepicker.fr.js"></script>--%>
<script src="${contextPath}/static/statistics/js/bootstrap-datetimepicker.zh-CN.js"></script>
<script src="${contextPath}/static/statistics/js/vue.js"></script>
<script src="${contextPath}/static/countjs/regularYz.js"></script>
<link href="${contextPath}/static/ztree/css/zTreeStyle.css" rel="stylesheet" />

<%--<jsp:include page="../../head.jsp"/>--%>

<style type="text/css">
    .customBtn {
        line-height: 20px;
        margin-bottom: 3px;
    }

    .btnLine {
        margin-left: 1px;
        margin-top: 8px;
        margin-bottom: 2px;
    }

    @-webkit-keyframes bouncedelay {
        0%, 80%, 100% {
            -webkit-transform: scale(0.0)
        }
        40% {
            -webkit-transform: scale(1.0)
        }
    }

    @keyframes bouncedelay {
        0%, 80%, 100% {
            transform: scale(0.0);
            -webkit-transform: scale(0.0);
        }
        40% {
            transform: scale(1.0);
            -webkit-transform: scale(1.0);
        }
    }

    .autocomplete-suggestions {
        border: 1px solid #999;
        background: #FFF;
        overflow: auto;
    }

    .autocomplete-suggestion {
        padding: 2px 5px;
        white-space: nowrap;
        overflow: hidden;
    }

    .autocomplete-selected {
        background: #F0F0F0;
    }

    .autocomplete-suggestions strong {
        font-weight: normal;
        color: #3399FF;
    }

    @-moz-document url-prefix() {
        fieldset {
            display: table-cell;
        }
    }

    .ui-jqgrid-sortable {
        text-align: center;
    }

    #cb_grid-table{margin-left: 10px;}

    .ui-pg-div{
        display: none;
    }
</style>
<div class="row" id="app">
    <div class="row btnLine">
        <div class="button-len col-sm-12">
            <div style="width: 100%; margin-bottom: 10px;">
                <button class="btn btn-white btn-sm btn-purple customBtn"  id="addProduct">
                    <i class="ace-icon fa fa-plus-circle purple"></i> 新增商品
                </button>
                <button class="btn btn-white btn-info btn-sm customBtn" id="addReqOrder">
                    <i class="ace-icon fa fa-pencil blue"></i> 发起要货
                </button>

                <%--<button class="btn btn-white btn-info btn-sm customBtn" id="">--%>
                    <%--<i class="ace-icon fa fa-pencil blue"></i> 调拨--%>
                <%--</button>--%>

                <label style="">选择店铺：</label>
                <select class="input-sm" id="shopId">
                    <option :value="obj.shopId" v-for="(obj, index) in arrayShop">{{ obj.shopName }}</option>
                </select>

                <button class="btn btn-white btn-sm btn-purple customBtn"  id="gatStockProduct" onclick="gatStockProduct()">
                    <i class="ace-icon fa fa-plus-circle purple"></i> 推荐商品
                </button>
                <%--<button class="btn btn-white btn-sm btn-purple customBtn" id="roleAuthorization">--%>
                    <%--<i class="ace-icon fa fa-plus-circle purple"></i> 测试按钮--%>
                <%--</button>--%>
                <%--<button class="btn btn-white btn-info btn-sm customBtn" id="deleteSupplier">--%>
                    <%--<i class="ace-icon fa fa-key red"></i> 删除--%>
                <%--</button>--%>
                <%--<button class="btn btn-white btn-info btn-sm customBtn" id="">--%>
                <%--<i class="ace-icon fa fa-key red"></i> 复制--%>
                <%--</button>--%>
                <%--<button class="btn btn-white btn-info btn-sm customBtn" id="">--%>
                <%--<i class="ace-icon fa fa-key red"></i> 打印--%>
                <%--</button>--%>
                <%--<button class="btn btn-white btn-info btn-sm customBtn" id="">--%>
                <%--<i class="ace-icon fa fa-key red"></i> 导出--%>
                <%--</button>--%>
                <%--<button class="btn btn-white btn-info btn-sm customBtn" id="">--%>
                <%--<i class="ace-icon fa fa-key red"></i> 设置--%>
                <%--</button>--%>
                <%--<button class="btn btn-white btn-info btn-sm customBtn" id="">--%>
                <%--<i class="ace-icon fa fa-key red"></i> 退出--%>
                <%--</button>--%>
                <input class="input-sm" type="text" id="keyword" style="margin-left: 0px;" value=""
                       placeholder="关键字">
                <button class="btn btn-sm btn-white btn-info search-len customBtn">
                    <i class="ace-icon fa fa-search orange"></i>搜索
                <%--onclick="searchShop()"--%>
                </button>
            </div>
        </div>
    </div>
    <!-- 内容数据开始 -->
    <div class="col-xs-12">
        <table id="grid-table"></table>

        <div id="grid-pager"></div>

    </div>

    <!-- 内容数据结束 -->

    <!-- 商品模态框（Modal） -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="width: 840px; height: 350px;">
            <div class="modal-content">
                <div class="modal-header" style="font-size: 20px; margin-bottom: -15px;">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        快速要货 - <span id="alertTitle">商品新增</span>
                        <small id="smallTitle" class="hide" style="color: red; float: right; margin-top: 10px;"></small>
                    </h4>
                </div>
                <div class="modal-body">
                    <div class="row" style="height: 100px;">
                        <table class="table">
                            <tbody>
                            <tr>
                                <th>
                                    <div class="row btnLine">
                                        <div class="button-len col-sm-12">
                                            <label for="" style="margin-left: 8px;">商品类型：</label>
                                            <select class="input-sm" id="isExpInput">
                                                <option value="">商品类型</option>
                                                <option :value="obj.typeId" v-for="(obj, index) in yanType1">
                                                    {{ obj.typeName }}
                                                </option>

                                            </select>
                                            <select class="input-sm" id="isAuthInput">
                                                <option value="-1">商品大类</option>
                                                <option :value="obj.typeId" v-for="(obj, index) in yanType2">
                                                    {{ obj.typeName }}
                                                </option>
                                            </select>

                                            <select class="input-sm" id="isAuthInput1">
                                                <option value="-1">商品中类</option>
                                                <option :value="obj.typeId" v-for="(obj, index) in yanType3">
                                                    {{ obj.typeName }}
                                                </option>
                                            </select>

                                            <select class="input-sm" id="isAuthInput2">
                                                <option value="-1">商品小类</option>
                                                <option :value="obj.typeId" v-for="(obj, index) in yanType4">
                                                    {{ obj.typeName }}
                                                </option>
                                            </select>
                                        </div>
                                    </div>
                                </th>
                            </tr>
                            <tr>
                                <th>
                                    <input class="input-sm" type="text" id="productCode" style="margin-left: 20px;"
                                           placeholder="商品条码">
                                    <input class="input-sm" type="text" id="productName" style="margin-left: 5px;"
                                           placeholder="商品名称">
                                    <button class="btn btn-sm btn-white btn-info search-len customBtn"
                                            onclick="searchShopProduct(grid_prod_selector,'包')">
                                        <i class="ace-icon fa fa-search orange"></i>搜索
                                    </button>
                                </th>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <!-- 内容数据开始 -->
                    <div class="button-len col-sm-12">
                        <table id="grid-prod-table"></table>
                        <div id="grid-prod-pager"></div>
                    </div>
                    <!-- 内容数据结束 -->
                    <div style="text-align: right;">
                        <button class="btn btn-white btn-info btn-sm customBtn btn-xs" type="button" id="appProd" style="margin-top: 10px; margin-right: 11px;">添加</button>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default btn-xs" data-dismiss="modal">关闭</button>
                    <%--<button type="button" class="btn btn-primary btn-xs" v-on:click="saveSupplier">提交更改</button>--%>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>

    <!-- 店铺选择模态框（Modal） -->
    <div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel1">
                        <span id="alertTitle1">店铺选择</span>
                        <small id="smallTitle1" class="hide" style="color: red; float: right; margin-top: 10px;">哈哈哈</small>
                    </h4>
                </div>
                <div class="modal-body">
                    <label for="" style="">店铺类型：</label>
                    <select class="input-sm" id="shopType">
                        <option value="">请选择</option>
                        <option value="中深">中深</option>
                    </select>

                    <input class="input-sm" type="text" id="shopName" style="margin-left: 2px;" placeholder="店铺名称">
                    <button class="btn btn-sm btn-white btn-info search-len customBtn" onclick="searchShopInfo()">
                        <i class="ace-icon fa fa-search orange"></i>搜索
                    </button>
                    <div class="row" style="border: #1b1e21 solid 1px;">
                        <table id="grid-shop-table"></table>
                        <div id="grid-shop-pager"></div>
                    </div>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <%--<button type="button" class="btn btn-primary btn-xs" v-on:click="saveSupplier">提交更改</button>--%>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
</div>
<!-- 数型内容 -->
<div id="authorizationInfoContent" class="hide">
    <div class="content_wrap">
        <div class="zTreeDemoBackground left" style="width: 190px;">
            <ul id="treeDemo" class="ztree"></ul>
        </div>
    </div>
</div>



<!-- page specific plugin scripts -->
<script type="text/javascript" src="${contextPath}/static/statistics/js/jquery.mockjax.js"></script>
<script type="text/javascript" src="${contextPath}/static/statistics/js/jquery.autocomplete.js"></script>
<script src=${contextPath}/static/layer/layui.all.js></script>
<script type="text/javascript">

    var grid_selector = "#grid-table";
    var pager_selector = "#grid-pager";

    var grid_shop_selector = "#grid-shop-table";
    var pager_shop_selector = "#grid-shop-pager";

    var grid_prod_selector = "#grid-prod-table";
    var pager_prod_selector = "#grid-prod-pager";

    //获取选择数据的Id，（获取单条数据id 使用selrow，获取多条数据Id 使用selarrrow）
//    var id = $(grid_selector).jqGrid('getGridParam', 'selrow');
    //获取选择数据的的整条数据（数据类型 集合）
//    var rowData = $(grid_selector).jqGrid('getRowData', id);
    //获取选择数据的Id，（数组类型）
//    var ids = $(grid_prod_selector).jqGrid('getGridParam', 'selarrrow');


    var laypage = layui.laypage,
        layer = layui.layer
    laydate = layui.laydate;

    var queryModel = {
        //分页参数
        page: '1',
        rows: '100',
    }

    var app = new Vue({
        el: '#app',
        data: {
            objcte: [],
            yanType1: [],
            yanType2: [],
            yanType3: [],
            yanType4: [],
            yanType5: [],
            arrayShop: [],
        },
        methods: {
        }
    })

    $("#addCargo").click(function () {
        prodInfo();
    });
    $("#addReqOrder").click(function () {
        submitReq()
    });
    $("#appProd").click(function () {
        addRowData();
    })

</script>

<!-- 商品下拉菜单 -->
<script>
    /**
     * 下啦联动数据绑定 开始代码
     * @type {{parentId: string}}
     */
    $('#isExpInput').change(function () {
        app.yanType2 = []
        app.yanType3 = []
        app.yanType4 = []
        $("#commodityScreen").addClass("hide");
        queryModel.parentId = $("#isExpInput option:selected").val();
        querySubProdType2()
    });

    $('#isAuthInput').change(function () {
        app.yanType3 = []
        app.yanType4 = []
        $("#commodityScreen").addClass("hide");
        queryModel.parentId = $("#isAuthInput option:selected").val();
        querySubProdType3()
    });

    $('#isAuthInput1').change(function () {
        app.yanType4 = []
        $("#commodityScreen").addClass("hide");
        queryModel.parentId = $("#isAuthInput1 option:selected").val();
        querySubProdType4()
    });

    $('#isAuthInput2').change(function () {
        app.yanType5 = []
        $("#commodityScreen").addClass("hide");
        queryModel.parentId = "";
        queryModel.typeId = $("#isAuthInput2 option:selected").val();
        querySubProdType5()
    });

    var querySubProdType1 = function () {
        getSubProdType1(queryModel)
    }
    var querySubProdType2 = function () {
        getSubProdType2(queryModel)
    }
    var querySubProdType3 = function () {
        getSubProdType3(queryModel)
    }
    var querySubProdType4 = function () {
        getSubProdType4(queryModel)
    }
    var querySubProdType5 = function () {
        getSubProdType5(queryModel)
    }


    var getSubProdType1 = function (queryModel) {
        // //console.log(queryModel)

//        layer.load(1)
        $.ajax({
            url: '${contextPath}/ktProd/getSubProdType',
            type: 'post',
            data: queryModel,
            success: function (data) {
//                layer.closeAll('loading');
                if (data.success == false){
                    layer.msg("获取出错："+data.message)
                    return
                }
                var dataArray = data;

                if (dataArray.length == 0){
                    layer.msg("查询没有数据")
                    return
                }
//                 //console.log("dataArray: "+dataArray)
                app.yanType1 = dataArray;

            },
            error: function (error) {
//                layer.closeAll('loading')
            }
        })
    }

    var getSubProdType2 = function (queryModel) {
        //console.log(queryModel)
        $.ajax({
            url: '${contextPath}/ktProd/getSubProdType',
            type: 'post',
            data: queryModel,
            success: function (data) {
                if (data.success == false){
                    layer.msg("获取出错："+data.message)
                    return
                }
                var dataArray = data;

                if (dataArray.length == 0){
                    layer.msg("查询没有数据")
                    return
                }
//                //console.log("dataArray: "+dataArray)
                app.yanType2 = dataArray;

            },
            error: function (error) {
            }
        })
    }

    var getSubProdType3 = function (queryModel) {
        //console.log(queryModel)
//        layer.load(1)
        $.ajax({
            url: '${contextPath}/ktProd/getSubProdType',
            type: 'post',
            data: queryModel,
            success: function (data) {
//                layer.closeAll('loading');
                if (data.success == false){
                    layer.msg("获取出错："+data.message)
                    return
                }
                var dataArray = data;

                if (dataArray.length == 0){
                    layer.msg("查询没有数据")
                    return
                }
//                //console.log("dataArray: "+dataArray)
                app.yanType3 = dataArray;

            },
            error: function (error) {
//                layer.closeAll('loading')
            }
        })
    }

    var getSubProdType4 = function (queryModel) {
        // //console.log(queryModel)
//        layer.load(1)
        $.ajax({
            url: '${contextPath}/ktProd/getSubProdType',
            type: 'post',
            data: queryModel,
            success: function (data) {
//                layer.closeAll('loading');
                if (data.success == false){
                    layer.msg("获取出错："+data.message)
                    return
                }
                var dataArray = data;

                if (dataArray.length == 0){
                    layer.msg("查询没有数据")
                    return
                }
//                //console.log("dataArray: "+dataArray)
                app.yanType4 = dataArray;

            },
            error: function (error) {
//                layer.closeAll('loading')
            }
        })
    }

    var getSubProdType5 = function (queryModel) {
        // //console.log(queryModel)
//        layer.load(1)
        $.ajax({
            url: '${contextPath}/ktProd/getProdProperty',
            type: 'post',
            data: queryModel,
            success: function (data) {
//                layer.closeAll('loading');
                if (data.success == false){
                    layer.msg("获取出错："+data.message)
                    return
                }
                var dataArray = data;

                if (dataArray.length == 0){
                    layer.msg("查询没有数据")
                    return
                }
                $("#commodityScreen").removeClass("hide");
//                //console.log("dataArray: "+dataArray)
                app.yanType5 = dataArray;

            },
            error: function (error) {
//                layer.closeAll('loading')
            }
        })
    }

    querySubProdType1(queryModel);

    /**
     * 下啦联动数据绑定 结束代码
     */
</script>

<!-- jqGrid 公用方法 -->
<script type="application/javascript">

    function style_edit_form(form) {
        //enable datepicker on "sdate" field and switches for "stock" field
        //form.find('input[name=sdate]').datepicker({format:'yyyy-mm-dd' , autoclose:true})

        //form.find('input[name=stock]').addClass('ace ace-switch ace-switch-5').after('<span class="lbl"></span>');
        //don't wrap inside a label element, the checkbox value won't be submitted (POST'ed)
        //.addClass('ace ace-switch ace-switch-5').wrap('<label class="inline" />').after('<span class="lbl"></span>');


        //update buttons classes
        var buttons = form.next().find('.EditButton .fm-button');
        buttons.addClass('btn btn-sm').find('[class*="-icon"]').hide();//ui-icon, s-icon
        buttons.eq(0).addClass('btn-primary').prepend('<i class="ace-icon fa fa-check"></i>');
        buttons.eq(1).prepend('<i class="ace-icon fa fa-times"></i>')

        buttons = form.next().find('.navButton a');
        buttons.find('.ui-icon').hide();
        buttons.eq(0).append('<i class="ace-icon fa fa-chevron-left"></i>');
        buttons.eq(1).append('<i class="ace-icon fa fa-chevron-right"></i>');
    }

    function style_delete_form(form) {
        var buttons = form.next().find('.EditButton .fm-button');
        buttons.addClass('btn btn-sm btn-white btn-round').find('[class*="-icon"]').hide();//ui-icon, s-icon
        buttons.eq(0).addClass('btn-danger').prepend('<i class="ace-icon fa fa-trash-o"></i>');
        buttons.eq(1).addClass('btn-default').prepend('<i class="ace-icon fa fa-times"></i>')
    }

    function style_search_filters(form) {
        form.find('.delete-rule').val('X');
        form.find('.add-rule').addClass('btn btn-xs btn-primary');
        form.find('.add-group').addClass('btn btn-xs btn-success');
        form.find('.delete-group').addClass('btn btn-xs btn-danger');
    }

    function style_search_form(form) {
        var dialog = form.closest('.ui-jqdialog');
        var buttons = dialog.find('.EditTable')
        buttons.find('.EditButton a[id*="_reset"]').addClass('btn btn-sm btn-info').find('.ui-icon').attr('class', 'ace-icon fa fa-retweet');
        buttons.find('.EditButton a[id*="_query"]').addClass('btn btn-sm btn-inverse').find('.ui-icon').attr('class', 'ace-icon fa fa-comment-o');
        buttons.find('.EditButton a[id*="_search"]').addClass('btn btn-sm btn-purple').find('.ui-icon').attr('class', 'ace-icon fa fa-search');
    }

    function beforeDeleteCallback(e) {
        var form = $(e[0]);
        if (form.data('styled')) return false;

        form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
        style_delete_form(form);
        form.data('styled', true);
    }

    function beforeEditCallback(e) {
        var form = $(e[0]);
        form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
        style_edit_form(form);
    }


    //it causes some flicker when reloading or navigating grid
    //it may be possible to have some custom formatter to do this as the grid is being created to prevent this
    //or go back to default browser checkbox styles for the grid
    function styleCheckbox(table) {
        /**
         $(table).find('input:checkbox').addClass('ace')
         .wrap('<label />')
         .after('<span class="lbl align-top" />')


         $('.ui-jqgrid-labels th[id*="_cb"]:first-child')
         .find('input.cbox[type=checkbox]').addClass('ace')
         .wrap('<label />').after('<span class="lbl align-top" />');
         */
    }


    //unlike navButtons icons, action icons in rows seem to be hard-coded
    //you can change them like this in here if you want
    function updateActionIcons(table) {
        /**
         var replacement =
         {
             'ui-ace-icon fa fa-pencil' : 'ace-icon fa fa-pencil blue',
             'ui-ace-icon fa fa-trash-o' : 'ace-icon fa fa-trash-o red',
             'ui-icon-disk' : 'ace-icon fa fa-check green',
             'ui-icon-cancel' : 'ace-icon fa fa-times red'
         };
         $(table).find('.ui-pg-div span.ui-icon').each(function(){
				var icon = $(this);
				var $class = $.trim(icon.attr('class').replace('ui-icon', ''));
				if($class in replacement) icon.attr('class', 'ui-icon '+replacement[$class]);
			})
         */
    }

    //replace icons with FontAwesome icons like above
    function updatePagerIcons(table) {
        var replacement =
            {
                'ui-icon-seek-first': 'ace-icon fa fa-angle-double-left bigger-140',
                'ui-icon-seek-prev': 'ace-icon fa fa-angle-left bigger-140',
                'ui-icon-seek-next': 'ace-icon fa fa-angle-right bigger-140',
                'ui-icon-seek-end': 'ace-icon fa fa-angle-double-right bigger-140'
            };
        $('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(function () {
            var icon = $(this);
            var $class = $.trim(icon.attr('class').replace('ui-icon', ''));

            if ($class in replacement) icon.attr('class', 'ui-icon ' + replacement[$class]);
        })
    }

    function enableTooltips(table) {
        $('.navtable .ui-pg-button').tooltip({container: 'body'});
        $(table).find('.ui-pg-div').tooltip({container: 'body'});
    }

    //var selr = jQuery(grid_selector).jqGrid('getGridParam','selrow');

    $(document).one('ajaxloadstart.page', function (e) {
        $.jgrid.gridDestroy(grid_selector);
        $('.ui-jqdialog').remove();
    });

    //重新加载数据
    var reload = function () {
//        $(grid_selector).jqGrid('clearGridData');  //清空表格
        $(grid_coupontype_selector).jqGrid('setGridParam',{
            url:"${contextPath}/ktSaleProject/getCardProdListByPage",
            datatype:'json',
//                    postData:param,
            page:1
        }).trigger("reloadGrid"); //重新载入
    }
</script>

<%--<script type="text/javascript" src="${contextPath}/static/ace/components/bootstrap-datepicker/dist/js/bootstrap-datepicker.js"></script>--%>
<%--<script type="text/javascript" src="${contextPath}/static/ace/components/jqGrid/js/jquery.jqGrid.js"></script>--%>
<%--<script type="text/javascript" src="${contextPath}/static/ace/components/jqGrid/js/i18n/grid.locale-cn.js"></script>--%>
<%--<script type="text/javascript" src="${contextPath}/static/layer/layer.js"></script>--%>
<%--<script type="text/javascript" src="${contextPath}/static/ztree/js/jquery.ztree.core-3.5.js"></script>--%>
<%--<script type="text/javascript" src="${contextPath}/static/ztree/js/jquery.ztree.excheck-3.5.js"></script>--%>
<!-- 缺货商品列表 -->
<script>

    var get = function (shopId) {
        //        var phone = $("#phone").val();
        //var parentDepartmentkey = $("#id_parentDepartmentkey_name").val();
        var filters = {
            "rules": [
                {
                    "field": "shopId",
                    "data": shopId
                }
            ]
        };
//        console.log(shopId)
        var scripts = [null, "${contextPath}/static/ace/components/bootstrap-datepicker/dist/js/bootstrap-datepicker.js", "${contextPath}/static/ace/components/jqGrid/js/jquery.jqGrid.js", "${contextPath}/static/ace/components/jqGrid/js/i18n/grid.locale-cn.js", "${contextPath}/static/layer/layer.js","${contextPath}/static/ztree/js/jquery.ztree.core-3.5.js", "${contextPath}/static/ztree/js/jquery.ztree.excheck-3.5.js", null]
        $('.page-content-area').ace_ajax('loadScripts', scripts, function () {
            jQuery(function ($) {
                var parent_column = $(grid_selector).closest('[class*="col-"]');
                //resize to fit page size
                $(window).on('resize.jqGrid', function () {
                    $(grid_selector).jqGrid( 'setGridWidth', parent_column.width() );
                })

                //resize on sidebar collapse/expand
                $(document).on('settings.ace.jqGrid' , function(ev, event_name, collapsed) {
                    if( event_name === 'sidebar_collapsed' || event_name === 'main_container_fixed' ) {
                        //setTimeout is for webkit only to give time for DOM changes and then redraw!!!
                        setTimeout(function() {
                            $(grid_selector).jqGrid( 'setGridWidth', parent_column.width() );
                        }, 20);
                    }
                })

                jQuery(grid_selector).jqGrid({
                    <%--url : '${contextPath}/ktProd/getRecommendProdByPage',--%>
//                    postData: {
//                        "filters": JSON.stringify(filters) //"{'rules' : [{'field' : 'shopName','data' : "+shopName+"},{'field' : 'state','data' : "+state+"}]}"
//                    },
                    datatype: "json",
                    mtype: 'POST',
                    height: 372,
                    colNames: ['编号', '商品名称', '类型', '条码','单位','规格', '现有库存', '要货数量', '商品来源','shopId', 'requireId', 'requireOrderItemId'],
                    colModel: [
                        {name: 'productId', index: 'productId', width: 30, editable: true, hidden: true},
                        {
                            name: 'productName',
                            index: 'productName',
                            width: 90,
                            editable: true,
                            sortable: false,
                            editrules: {required: true}
                        },
                        {
                            name: 'prodTypeName',
                            index: 'prodTypeName',
                            width: 60,
                            editable: true,
                            sortable: false,
                            editrules: {required: true}
                        },
                        {
                            name: 'productCode',
                            index: 'productCode',
                            width: 60,
                            editable: true,
                            dataType: 'int',
                            sortable: true,
                            sortable: false,
                            editrules: {required: true}
                        },
                        {
                            name: 'unit',
                            index: 'unit',
                            width: 30,
                            editable: true,
                            sortable: false
                        },
                        {
                            name: 'spec',
                            index: 'spec',
                            width: 60,
                            editable: true,
                            sortable: false
                        },
                        {
                            name: 'stockSpec',
                            index: 'stockSpec',
                            width: 60,
                            editable: true,
                            sortable: false,
                            align: 'right',
                            formatter:function(cellvalue, options, rowObject) {
                                var stockSpec = rowObject['stockSpec'];
                                if(!stockSpec){
                                    return '0'
                                }
                                return stockSpec;
                            }
                        },
                        {
                            name: 'quantity',
                            index: 'quantity',
                            width: 60,
                            editable: true,
                            sortable: false,
                            align: 'right',
                            formatter:function(cellvalue, options, rowObject) {
                                var quantity = rowObject.quantity;
                                var productCode = rowObject.productCode;
                                if(!quantity){
                                    quantity = ''
                                }
                                return ' <input type="text" id="quantity_'+productCode+'" value="'+quantity+'" placeholder="0" style="background-color: #ffffff ;border:0; outline:0;size: 13; margin-top: -16px;float: right; text-align: right;" placeholder="'+quantity+'"/>';
                            }
                        },
                        {
                            name: 'requireShopName',
                            index: 'requireShopName',
                            width: 60,
                            editable: true,
                            sortable: false,
                            formatter:function(cellvalue, options, rowObject) {
                                var id = rowObject.productCode;
                                if(!cellvalue){
                                    cellvalue = "总部";
                                }
                                return '<div onclick="requireShopNameFu('+id+')" name="requireShopName" id="requireShopName_'+rowObject.productCode+'">'+cellvalue+'</div>';
                            }
                        },
                        {
                            name: 'requireShopId',
                            index: 'requireShopId',
                            width: 60,
                            editable: true,
                            hidden:true,
                            sortable: false,
                            formatter:function(cellvalue, options, rowObject) {
                                if(!cellvalue){
                                    cellvalue = '0'
                                }
                                return '<div id="requireShopId_'+rowObject.productCode+'">'+cellvalue+'</div>';
                            }
                        },
                        {
                            name: 'requireId',
                            index: 'requireId',
                            editable: true,
                            hidden:true,
                            sortable: false,
                            align: 'right',
                        },
                        {
                            name: 'requireOrderItemId',
                            index: 'requireOrderItemId',
                            editable: true,
                            hidden:true,
                            sortable: false,
                            align: 'right',
                        },
                    ],

                    rownumbers: true, //自动行数

                    autowidth:true,  //宽度自适应
                    viewrecords: true,
                    rowNum : 10,//一页显示多少条
                    rowList : [ 10, 20, 30 ],//可供用户选择一页显示多少条
                    pager : pager_selector,//表格页脚的占位符(一般是div)的id
                    sortname : 'gmtModifiedStr',//初始化的时候排序的字段
                    sortorder : "desc",//排序方式,可选desc,asc
                    altRows: true,
                    multiselect: true,
                    multiboxonly: false,
                    loadComplete: function () {
                        var table = this;
                        setTimeout(function () {
                            styleCheckbox(table);
                            updateActionIcons(table);
                            updatePagerIcons(table);
                            enableTooltips(table);
                        }, 0);
                    },

                    <%--editurl: "${contextPath}/ktProd/getRecommendProdByPage",//nothing is saved--%>
                    caption: "缺货商品列表",
                    jsonReader: {
                        root: "recordList",
                        page: "currentPage",
                        total: "pageCount",
                        records: "recordCount"
                    },

                });

                $("#addProduct").click(function () {
                    var o = $(grid_selector);
                    //获取当前显示的数据
                    var rowNum = o.jqGrid('getGridParam', 'rowNum'); //获取显示配置记录数量
                    var total = o.jqGrid('getGridParam', 'records'); //获取查询得到的总记录数量
                    //设置rowNum为总记录数量并且刷新jqGrid，使所有记录现出来调用getRowData方法才能获取到所有数据
                    o.jqGrid('setGridParam', { rowNum: total }).trigger('reloadGrid');

                    prodInfo('${contextPath}', grid_prod_selector, pager_prod_selector,'包');

                    $('#myModal').modal('show');
                })

                jQuery(grid_selector).jqGrid('navGrid', '#addpager', {
                    edit : false,
                    add : false,
                    del : false,
                    search : false
                });

                $(window).triggerHandler('resize.jqGrid');//trigger window resize to make the grid get the correct size

                $("#jqgh_grid-coupontype-table_rn").html('');
                $("#grid-coupontype-table_rn").css('width', '36px');
            });
        });
    }

    //修改调用
    var getSupplier = function (rowData) {
        queryModel.id = rowData.id;
//        //console.log(queryModel)
        layer.load(1)
        $.ajax({
            url: '${contextPath}/ktPurchase/getSupplier',
            type: 'post',
            data: queryModel,
            success: function (data) {
                layer.closeAll('loading');
                if (data.success == false){
                    layer.msg("获取出错："+data.message)
                    return
                }
                var dataArray = data.data;
                if (dataArray.length == 0){
                    layer.msg("查询没有数据")
                    return
                }
//                //console.log(dataArray)
                editShop(dataArray);
            },
            error: function (error) {
                layer.closeAll('loading')
            }
        })
    };

</script>
<!-- 商品列表详情 -->
<script type="text/javascript" src="${contextPath}/static/franchisee/alertProdInfo.js"></script>


<!-- 业务处理 -->
<script type="text/javascript">

    var gatStockProduct = function () {
        var shopId = $("#shopId").val();
        var filters = {
            "rules": [
                {
                    "field": "shopId",
                    "data": shopId
                }
            ]
        };
        console.log(filters)
        $(grid_selector).jqGrid('setGridParam',{
            url : '${contextPath}/ktProd/getRecommendProdByPage',
            datatype:'json',
            postData:{ filters: JSON.stringify(filters) },
        page:1
        }).trigger("reloadGrid"); //重新载入
    }

    var requireShopNameFu = function (id) {
//        alert(id);
//        var id = $(grid_selector).jqGrid('getGridParam', 'selrow');
//        var rowData = $(grid_selector).jqGrid('getRowData', id);

        pageInit(id)
        $('#myModal1').modal('show');
    }

//    requireShopNameFu("1")
    /**
     * 搜索店铺
     */
    function searchShopInfo() {

//        $('#myModal').modal('show');


        var shopType = $("#shopType").val();
        var shopName = $("#shopName").val();
//        if (priceType == "0"){
//            layer.msg("提示：请选择价格类型！")
//            return
//        }
        //console.log(shopName);
        var filters = {
            "rules": [
                {
                    "field": "shopName",
                    "data": shopName
                },
                {
                    "field": "shopType",
                    "data": shopType
                }
            ]
        };
        //console.log(filters);

        jQuery("#grid-shop-table").jqGrid('setGridParam', {
            postData: {
                "filters": JSON.stringify(filters) //"{'rules' : [{'field' : 'shopName','data' : "+shopName+"},{'field' : 'state','data' : "+state+"}]}"
            }
        }).trigger("reloadGrid");
    }

    var quantityId = '';
    var submitReq = function () {
        layer.closeAll('loading');
//        var id = $(grid_selector).jqGrid('getGridParam', 'selrow');
        var ids = $(grid_selector).jqGrid('getGridParam', 'selarrrow');
        if (ids.length == 0){
            layer.closeAll('loading');
            layer.msg("你没有选择添加商品！");
            return;
        }
        var requireShopId = '';
        var prodList = [];
        for(var i=0;i<ids.length;i++){
            var rowData = $(grid_selector).jqGrid('getRowData', ids[i]);
            var idArray = {};
            idArray.productCode = rowData.productCode;
            var requireShopId = '';
            quantityId = "#quantity_"+rowData.productCode;
            var quantity = $(quantityId).val();
            //console.log($(quantityId).val())
            //console.log(quantity)
            if (quantity == '0'){
                layer.closeAll('loading');
                layer.msg("提示："+rowData.productName+"商品没有要货数不能为0！");
                return;
            }
            if(requireShopId != ''){
//                //console.log(requireShopId)
//                //console.log(idArray.requireShopId)
                if(idArray.requireShopId != requireShopId){
                    layer.closeAll('loading');
                    layer.msg("提示：商品来源不一致不能提交");
                    return;
                }
            }
            console.log(rowData.requireShopId)
            requireShopId = rowData.requireShopId;
            idArray.quantity = quantity;
            idArray.requireId = rowData.requireId;
            idArray.requireOrderItemId = rowData.requireOrderItemId;
            idArray.type = '2';
            idArray.status = '';
            prodList.push(idArray);
        }
        prodList.id = idArray;
//        //console.log(JSON.stringify(prodList));
        queryModel.prodList = JSON.stringify(prodList);
        queryModel.shopId = $("#shopId").val();
        queryModel.type = '2';
        console.log(queryModel)
//        queryModel.id = id;
        $.ajax({
            url: '${contextPath}/ktPurchase/saveShopRequireOrder',
            type: 'post',
            data: queryModel,
            success: function (data) {
                layer.closeAll('loading');
                if (data.success == false){
                    layer.msg("获取出错："+data.message)
                    return
                }
                var dataArray = data;
                layer.msg("提示："+data.message)
                reload()
            },
            error: function (error) {
                layer.closeAll('loading')
                layer.msg("提示：服务器异常")
            }
        })
    }

    /*************  新增商品 **********/
    /*2.把dataRow添加到表格中*/
    function addRowData(){
        var ids = $(grid_prod_selector).jqGrid('getGridParam', 'selarrrow');
        var len = ids.length;
        if(len == 0){
            layer.msg("提示：您还没有选择商品");
            return
        }

        for(var i=0;i<len;i++) {
            var newrowid = 0;
            var idss = $(grid_selector).jqGrid('getDataIDs');
            console.log(idss)
            if (idss.length > 0) {
                //获得当前最大行号（数据编号）
                var rowid = Math.max.apply(Math, idss);
                //获得新添加行的行号（数据编号）
                newrowid = rowid + 1;
            }
            var rowData = $(grid_prod_selector).jqGrid('getRowData', ids[i]);
            var productCode = rowData.productCode;
            getProdSupplier(productCode);
            rowData.requireShopName = rowData.supplierName;
            rowData.requireShopId = rowData.supplierId;
            if(vyProductCode(productCode)){
               console.log(rowData)
                $(grid_selector).jqGrid("addRowData", newrowid, rowData, "last");
            }else {
                layer.msg("提示：商品已经添加");
                return;
            }
        }
    }
    //判断商品是否添加
    var vyProductCode = function (productCode) {
        var rows = $(grid_selector).jqGrid('getRowData');  //此时获取表格所有匹配的
        console.log(rows)
        var str = true;
        var idsGr = $(grid_selector).jqGrid("getRowData");

        for(var i=0;i<rows.length;i++){
            var productCodeGr = rows[i].productCode;
            if (productCode == productCodeGr) {
                str = false;
            }
        }
        return str;
    }

    //获取当前表格的所有数据
    function getJQAllData() {
        var o = $(grid_selector);
        //获取当前显示的数据
        var rowNum = o.jqGrid('getGridParam', 'rowNum'); //获取显示配置记录数量
        console.log(rowNum)
        var total = o.jqGrid('getGridParam', 'records'); //获取查询得到的总记录数量
        console.log(total)
        //设置rowNum为总记录数量并且刷新jqGrid，使所有记录现出来调用getRowData方法才能获取到所有数据
        o.jqGrid('setGridParam', { rowNum: total }).trigger('reloadGrid');
        var rows = o.jqGrid('getRowData');  //此时获取表格所有匹配的

        o.jqGrid('setGridParam', { rowNum: rowNum }).trigger('reloadGrid'); //还原原来显示的记录数量

        return rows;
    }

    var colls = function () {
        $(grid_selector).jqGrid('setGridParam', { rowNum: 10 }).trigger('reloadGrid'); //还原原来显示的记录数量
    }

    /**************************************/

    //根据productCode 获取供应商
    var getProdSupplier = function (productCode) {
        var dataList = {};
        dataList.productCode = productCode;
        $.ajax({
            url: '${contextPath}/ktProd/getProdSupplier',
            type: 'post',
            data: dataList,
            success: function (data) {
                var dataArray = data;
//                console.log(data);
                var supplierName = dataArray.supplierName;
                var supplierId = dataArray.supplierId;

            },
            error: function (error) {
            }
        })
    }


     /**
     * 搜索店铺
     */
    function searchShop() {
        var keyword = $("#keyword").val();
//        var phone = $("#phone").val();
        //var parentDepartmentkey = $("#id_parentDepartmentkey_name").val();

        var filters = {
            "rules": [{
                "field": "keyword",
                "data": keyword
            }]
        };
        jQuery("#grid-table").jqGrid('setGridParam', {
            postData: {
                "filters": JSON.stringify(filters) //"{'rules' : [{'field' : 'shopName','data' : "+shopName+"},{'field' : 'state','data' : "+state+"}]}"
            }
        }).trigger("reloadGrid");
    }


    var reload = function () {
        $(grid_selector).jqGrid('clearGridData');  //清空表格
        <%--$(grid_selector).jqGrid('setGridParam',{--%>
            <%--url:"${contextPath}/ktProd/getRecommendProdByPage",--%>
            <%--datatype:'json',--%>
<%--//                    postData:param,--%>
            <%--page:1--%>
        <%--}).trigger("reloadGrid"); //重新载入--%>
    }

    var getShop = function () {
        queryModel.state = '5';
        queryModel.shopType = "'中深'";

        $.ajax({
            url: '${contextPath}/ktCommon/getShopList2User',
            type: 'post',
            data: queryModel,
            success: function (data) {
                var dataArray = data;
                console.log(data)
                app.arrayShop = dataArray;
                get(dataArray[0].shopId);
            },
            error: function (error){
                get();
                layer.msg("获取出错："+data.message)
            }
        })
    }
    getShop();
    $('#shopId').change(function () {

        var shopId = $("#shopId").val();
//        alert(shopId)
        var filters = {
            "rules": [
                {
                    "field": "shopId",
                    "data": shopId
                }
            ]
        };
        console.log(filters)
        $(grid_selector).jqGrid('setGridParam',{
            url: "${contextPath}/ktProd/getRecommendProdByPage",
            datatype: 'json',
            postData: {
                "filters": JSON.stringify(filters) //"{'rules' : [{'field' : 'shopName','data' : "+shopName+"},{'field' : 'state','data' : "+state+"}]}"
            },
            page:1
        }).trigger("reloadGrid"); //重新载入
        <%--jQuery(grid_selector).jqGrid('setGridParam', {--%>
            <%--&lt;%&ndash;url : '${contextPath}/ktProd/getRecommendProdByPage',&ndash;%&gt;--%>
            <%--postData: {--%>
                <%--"filters": JSON.stringify(filters) //"{'rules' : [{'field' : 'shopName','data' : "+shopName+"},{'field' : 'state','data' : "+state+"}]}"--%>
            <%--}--%>
        <%--}).trigger("reloadGrid");--%>
    })

    /**
     * 搜索商品

    var searchShopProduct = function() {
        var supplierName = $("#supplierName").val();
        var productCode = $("#productCode").val();
        var state = $("#state1").val();
        var productName = $("#productName").val();
        var typeId = queryModel.parentId == null ? "0" : queryModel.parentId;

        var filters = {
            "rules": [
                {"field": "productCode", "data": productCode},
                {"field": "productName", "data": productName},
//                {"field": "supplierName", "data": supplierName},
                {"field": "typeId", "data": typeId},
//                {"field": "state", "data": state}
            ]
        };
        console.log(JSON.stringify(filters))
        jQuery(grid_prod_selector).jqGrid('setGridParam', {
            postData: {
                "filters": JSON.stringify(filters) //"{'rules' : [{'field' : 'shopName','data' : "+shopName+"},{'field' : 'state','data' : "+state+"}]}"
            }
        }).trigger("reloadGrid");
    }
     */
</script>

<!-- 数型插件 -->
<script type="text/javascript">
    $("#roleAuthorizationBtn").click(function () {
        var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
            nodes = zTree.getChangeCheckedNodes();
        if (nodes.length == 0) {
            layer.msg("权限没有被修改")
            return
        }
//        layer.load(1);
        var checkedNode = [];//用来存储被选择的节点
        var cancelCheckedNode = []; //用来存储被取消选择的节点
//        for (var i = 0, l = nodes.length; i < l; i++) {
//            if (nodes[i].checked) {
//                checkedNode = checkedNode.concat(nodes[i].id);
//            } else {
//                cancelCheckedNode = cancelCheckedNode.concat(nodes[i].id);
//            }
//        }
        checkedNode = nodes[nodes.length-1].zoneName
        //console.log(checkedNode)
        //console.log(cancelCheckedNode)
        $("#zoneName").val(nodes[nodes.length-1].zoneName);
        $("#zoneCode").val(nodes[nodes.length-1].zoneCode);
        layer.close(modalIndex)

    });

    $("#roleAuthorization").click(function(){
        var id = $(grid_selector).jqGrid('getGridParam', 'selrow');
//        if (!id) {
//            $.jgrid.info_dialog( "提示：", "请选择一条角色信息");
//            return;
//        }
        layer.load(1);

        var setting = {
            view: {
                dblClickExpand: false,
                showLine: true,
                selectedMulti: false
            },
            data: {
                simpleData: {
                    enable: true ,
                    idKey: "id",
                    pIdKey: "parentId",
                    rootPId: null,
                }
            },

            callback:{ //回调函数
                /**
                 * event:鼠标事件
                 * treeId：树的容器id
                 * treeNode：当前点击的节点
                 */
                expand:function(event,treeId,treeNode){
                    //console.log(treeId)
                    tree.pNode = treeNode;
                    tree.loadNodeByPNode();

                }
            }
//
//            callback: {
//                beforeClick: function(treeId, treeNode) {
//                    var zTree = $.fn.zTree.getZTreeObj("treeDemo");
//                    if (treeNode.isParent) {
//                        zTree.expandNode(treeNode);
//                        return false;
//                    } else {
//                        return true;
//                    }
//                },
//                onDblClick: function(treeId, treeNode) {
//                    //console.log(treeId)
//                }
//            }
        };

//        var setting = {
//            check: {
//                enable: true,
//                chkStyle: "radio",
//                //chkboxType: { "Y" : "p", "N" : "ps" }
//            },
//            data: {
//                simpleData: {
//                    enable: true ,
//                    idKey: "Id",
//                    pIdKey: "parentId",
//                    rootPId: null,
//                }
//            },
//            onDblClick: function(treeId, treeNode) {
//                alert(treeId)
//            },
//            view: {
//                dblClickExpand: false,
//                showLine: true,
//                selectedMulti: false
//            },
//        };

        var zNodes =[];
        //console.log(queryModel)
        queryModel.rows = '10000';
        $.ajax({
            url : "${contextPath}/ktProd/getProdType",
            type : "get",
            data : queryModel,
            dataType : "json",
            async : false,
            success : function(data) {
                layer.closeAll('loading');
                var dataArray = data.recordList;

                //console.log(dataArray)

                for (var i=0;i<dataArray.length;i++){
                    var array = dataArray[i];
                    array.name = array.typeName;
                    zNodes.push(array)
                }
                //console.log(zNodes)

                $.fn.zTree.init($("#treeDemo"), setting, zNodes);
                $("#authorizationInfoContent").removeClass("hide")
                modalIndex = layer.open({
                    type: 1,
                    title: '商品列表',
                    closeBtn: 1,
                    shadeClose: true,
                    maxmin: true,
                    area: ['200px', '550px'],
                    skin: 'yourclass',
                    content: $("#authorizationInfoContent"),
                    end: function () {
                        $("#authorizationInfoContent").addClass("hide")
                    }
                });
            },
            error : function () {
                layer.closeAll('loading');
                layer.msg("网络异常")
            }
        });
    })

</script>
<!-- 店铺加载 -->
<script type="text/javascript">
    // 加载店铺列表



    var requireShopId = '';
    var requireShopName = '';
    function pageInit(productCode){
//        var filters = {
//            "rules": [
//                {
//                    "field" : "state",
//                    "data": '1'
//                }
//            ]
//        };
//        var dataArray = []
//        dataArray.filters = JSON.stringify(filters);

        //console.log(queryModel)
        requireShopName = "#requireShopName_"+productCode;
        requireShopId = "#requireShopId_"+productCode;

        jQuery(grid_shop_selector).jqGrid({
            subGrid: false,
            url : '${contextPath}/ktProd/getShopListByPage',
            datatype: "json",
            postData: queryModel,
            mtype: 'POST',
            height: 300,
            colNames: ['店铺编号', '店铺名称'],
            colModel: [
                {name: 'shopId', index: 'shopId', width: 200, editable: true, key: true},
//                    {
//                        name: 'row',
//                        index: 'row',
//                        width: 90,
//                        editable: true,
//                        sortable: false,
//                        editrules: {required: true}
//                    },
                {
                    name: 'shopName',
                    index: 'shopName',
                    width: 350,
                    editable: true,
                    sortable: false,
                    editrules: {required: true}
                }

            ],
//                rownumbers: true, //自动行数
            height:"100%",   //高度自适应
//			width: "100%",
            autowidth: true,  //宽度自适应
//            viewrecords: true,
            rowNum: 10,
            rowList: [10, 20, 30],
            pager: pager_shop_selector,
            altRows: true,
            //toppager: true,

            multiselect: true,
            //multikey: "ctrlKey",
            multiboxonly: false,

            loadComplete: function () {
                var table = this;
                setTimeout(function () {
                    styleCheckbox(table);

                    updateActionIcons(table);
                    updatePagerIcons(table);
                    enableTooltips(table);
                }, 0);
            },

            editurl: "${contextPath}/ktProd/getShopListByPage",//nothing is saved
//            caption: "店铺列表",
            jsonReader: {
                root: "recordList",
                page: "currentPage",
                total: "pageCount",
                records: "recordCount"
            },
            ondblClickRow: function () {
                var shopId = $(grid_shop_selector).jqGrid('getGridParam', 'selrow');
                var rowData = $(grid_shop_selector).jqGrid('getRowData', shopId);

                var shopId = $("#shopId").val();
                if (shopId == rowData.shopId){
                    layer.msg("提示：商品来源不能选择自己")
                    return
                }
                ssaa(rowData)
                $('#myModal1').modal('hide');
            }

//                onSelectAll: function(rowids,statue){
//                    //函数里做自己的处理
//					queryModel.rowIds = rowids;
//                },
//                resetSelection: function(rowid){
//
//                    return(rowid)
//				}

            //,autowidth: true,


            /**
             ,
             grouping:true,
             groupingView : {
				 groupField : ['name'],
				 groupDataSorted : true,
				 plusicon : 'fa fa-chevron-down bigger-110',
				 minusicon : 'fa fa-chevron-up bigger-110'
			},
             caption: "Grouping"
             */

        });
        //it causes some flicker when reloading or navigating grid
        //it may be possible to have some custom formatter to do this as the grid is being created to prevent this
        //or go back to default browser checkbox styles for the grid
        function styleCheckbox(table) {
            /**
             $(table).find('input:checkbox').addClass('ace')
             .wrap('<label />')
             .after('<span class="lbl align-top" />')


             $('.ui-jqgrid-labels th[id*="_cb"]:first-child')
             .find('input.cbox[type=checkbox]').addClass('ace')
             .wrap('<label />').after('<span class="lbl align-top" />');
             */
        }


        //unlike navButtons icons, action icons in rows seem to be hard-coded
        //you can change them like this in here if you want
        function updateActionIcons(table) {
            /**
             var replacement =
             {
                 'ui-ace-icon fa fa-pencil' : 'ace-icon fa fa-pencil blue',
                 'ui-ace-icon fa fa-trash-o' : 'ace-icon fa fa-trash-o red',
                 'ui-icon-disk' : 'ace-icon fa fa-check green',
                 'ui-icon-cancel' : 'ace-icon fa fa-times red'
             };
             $(table).find('.ui-pg-div span.ui-icon').each(function(){
				var icon = $(this);
				var $class = $.trim(icon.attr('class').replace('ui-icon', ''));
				if($class in replacement) icon.attr('class', 'ui-icon '+replacement[$class]);
			})
             */
        }

        //replace icons with FontAwesome icons like above
        function updatePagerIcons(table) {
            var replacement =
                {
                    'ui-icon-seek-first': 'ace-icon fa fa-angle-double-left bigger-140',
                    'ui-icon-seek-prev': 'ace-icon fa fa-angle-left bigger-140',
                    'ui-icon-seek-next': 'ace-icon fa fa-angle-right bigger-140',
                    'ui-icon-seek-end': 'ace-icon fa fa-angle-double-right bigger-140'
                };
            $('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(function () {
                var icon = $(this);
                var $class = $.trim(icon.attr('class').replace('ui-icon', ''));

                if ($class in replacement) icon.attr('class', 'ui-icon ' + replacement[$class]);
            })
        }

        function enableTooltips(table) {
            $('.navtable .ui-pg-button').tooltip({container: 'body'});
            $(table).find('.ui-pg-div').tooltip({container: 'body'});
        }

        //var selr = jQuery(grid_selector).jqGrid('getGridParam','selrow');

        $(document).one('ajaxloadstart.page', function (e) {
            $.jgrid.gridDestroy(grid_selector);
            $('.ui-jqdialog').remove();
        });

        $(window).triggerHandler('resize.jqGrid');//trigger window resize to make the grid get the correct size
    }

    var ssaa = function (rowData) {
        $(requireShopName).html(rowData.shopName);
        $(requireShopId).html(rowData.shopId);
    }
</script>